{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Propositional Satisfiability Transformer Experiment"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Imports"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from ml2.prop.prop_sat_transformer_experiment import PropSatTransformerExperiment"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Load Experiment"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "INFO:ml2.artifact:Found experiment t-6 locally\n",
      "INFO:ml2.experiment:Initialized experiment with arguments:\n",
      "alpha: 0.5\n",
      "batch_size: 256\n",
      "beam_size: 1\n",
      "cache_dataset: True\n",
      "checkpoint_monitor: val_accuracy_per_sequence\n",
      "custom_pos_enc: True\n",
      "d_embed_dec: 128\n",
      "d_embed_enc: 128\n",
      "d_ff: 1024\n",
      "dataset_name: rfa-0\n",
      "drop_batch_remainder: True\n",
      "dropout: 0.0\n",
      "dtype_float: <dtype: 'float32'>\n",
      "dtype_int: <dtype: 'int32'>\n",
      "ff_activation: relu\n",
      "group: None\n",
      "initial_steps: 0\n",
      "max_input_length: 128\n",
      "max_target_length: 128\n",
      "name: t-6\n",
      "num_heads: 4\n",
      "num_layers_dec: 4\n",
      "num_layers_enc: 4\n",
      "parent_name: \n",
      "props: ['a', 'b', 'c', 'd', 'e']\n",
      "shuffle_on_load: True\n",
      "steps: 30000\n",
      "stream_to_wandb: False\n",
      "tf_shuffle_buffer_size: 0\n",
      "val_freq: 100\n",
      "wandb_run_id: 1gb1yhai\n",
      "warmup_steps: 4000\n",
      "WARNING:ml2.experiment:Experiment t-6 already exists locally\n"
     ]
    }
   ],
   "source": [
    "experiment = PropSatTransformerExperiment.load('t-6')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Call Model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "INFO:root:Constructed vocabulary containing 11 tokens\n",
      "INFO:ml2.seq2seq_experiment:Initialized input encoder\n",
      "2022-01-03 13:49:26.469511: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA\n",
      "To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n",
      "INFO:root:Constructed vocabulary containing 10 tokens\n",
      "INFO:ml2.seq2seq_experiment:Initialized target encoder\n",
      "INFO:ml2.experiment:Created evaluation model\n",
      "INFO:ml2.experiment:Found checkpoint /Users/Frederik/ml2-storage/prop-sat/t-6/checkpoint\n",
      "INFO:ml2.experiment:Loaded weights from checkpoint\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[{'assignment': 'a 1 b 0'}]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "experiment.call('a & ! b')"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "a142c9c21721142bd797377cddfc1c796fe902a53b9b843fc44c955c014dd320"
  },
  "kernelspec": {
   "display_name": "Python 3.8.12 64-bit ('ml2': pyenv)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.12"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
